/**
 * 格式化时间
 *
 * @param {string} t
 * @returns hh:mm:ss
 */
function formatTime (t) {
	let time = Number(t)
	let hh = 0
	let mm = 0
	let ss = 0
	if (time > 1000 * 60 * 60) {
		hh = Math.trunc(time / (1000 * 60 * 60))
		time -= 1000 * 60 * 60 * hh
	}
	if (time > 1000 * 60) {
		mm = Math.trunc(time / (1000 * 60))
		time -= 1000 * 60 * mm
	}
	if (time > 0) {
		ss = Math.trunc(time / 1000)
	}
	ss = Math.trunc(time / 1000)
	if (hh > 0) {
		return (
			(hh > 9 ? hh : '0' + hh) +
			':' +
			(mm > 9 ? mm : '0' + mm) +
			':' +
			(ss > 9 ? ss : '0' + ss)
		)
	}
	return (mm > 9 ? mm : '0' + mm) + ':' + (ss > 9 ? ss : '0' + ss)
}

export default formatTime
